import tango.io.Console;
import Text = tango.text.Util;

void main()
{
        char[] source = "all cows eat grass";

        // replace "eat" with "chew"
        char[] replaced = Text.substitute (source, "eat", "chew");
        Cout(replaced).newline;

        // incrementally replace "eat" with "chew", sans heap activity
        foreach (element; Text.patterns (source, "eat", "chew"))
                 Cout(element);
        Cout.newline;
}